﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;

namespace blackhouse.WebNemo.Data {
    public interface IDataAccess {

        void SaveGroup(int id, string displayName, string identyficatorFormat, bool supportTransate, bool readOnly);
        void DeleteGroup(int id);
        GroupData[] GetAllGroups();
        GroupData GetGroup(int groupId);
        bool CheckGroupName(string checkName);
        DataTable GetGroupScheme(FromGroup[] groups);
        GroupColumnData[] GetColumns(int groupId);
        GroupRecordData GetGroupRecord(SelectColumn[] selectColumns, int recordId, FromGroup[] groups, string language);
        GroupRecordData[] GetGroupRecords(SelectColumn[] selectColumns, WhereColumn[] whereColumns, FromGroup[] groups, string language);
        /// <summary>
        /// Pobiera rekordy za pomocą procedury. Procedura musi zwracać wszystkie kolumny (czyli SELECT * ...)
        /// Dodatkowo, procedura jako parametr standardowo przyjmuje Language
        /// </summary>
        GroupRecordData[] GetGroupRecords(SelectColumn[] selectColumns, ProcedureQuery procedure, FromGroup[] groups, string language);
        GroupRecordData[] GetRelatedGroupRecords(SelectColumn[] columns, FromGroup[] groups, WhereColumn[] whereClauses, string language);
        void RemoveRelationToGroupRecord(int relGroupId, int relRecordId, int parentGroupId, string parentColumnName, int parentRecordId);
        void AddRelationToGroupRecord(int relGroupId, int relRecordId, int parentGroupId, string parentColumnName, int parentRecordId, int userId);
        void ChangeIdentyficator(int groupId, int recordId, string ident, int userId);
        void RemoveRecord(int groupId, int recordId, int userId);
        void SaveGroupRecord(GroupRecordData data, int groupId, int recordId, int userId);
        int AddGroupRecord(GroupRecordData data, int groupId, int userId);
        void SaveGroupRecordFile(int groupId, int recordId, string column, string fileName, Stream stream, long streamSize, int userId);
        NemoUserData[] GetNemoUsers();

        KeyValuePair<int, string>[] GetGroupSystemNames();

        string[] GetAvalibleLanguages();
        string GetTranslate(int groupId, int fieldId, int recordId, string language);
        string GetOryginalTranslate(int groupId, int fieldId, int recordId);
        void SetTranslate(int groupId, int fieldId, int recordId, string language, string value, int userId);
        CustomValidatorData[] GetColumnValueValidators(int columnId);
        string GetCustomEditControlConfiguration(int columnId);

        TabData[] GetTabsForGroup(int groupId);
        SplitColumnsData[] GetColumnsSplit(int groupId);
        VirtualColumnData[] GetVirtualColumns(int groupId);
        void RemoveTranslate(int groupId, int fieldId, int recordId, string language);
        int CreateGroup(string systemName);

        Dictionary<int, string> GetFileGuids(string tableName, string columnName);
        byte[] GetFileStream(string columnName, int tableId, int recordId);
        byte[] GetFileStream(string columnName, string tableName, int recordId);
        FileData GetFileInfo(string columnName, int tableId, int recordId);
        FileData GetFileInfo(string columnName, string tableName, int recordId);

        ExtensionData GetExtensions(int groupId);
        void SaveExtensions(int groupId, string groupExtension, string groupRecordExtension);


        bool CheckViewDeclaration(string selectDeclaration);

        int CreateView(string systemName, string selectDeclaration);
    }
}
